package com.example.frn.dao;

import com.example.frn.dto.PageDTO;
import com.example.frn.dto.ReviewPageDto;
import com.example.frn.entity.RankingList;
import com.example.frn.entity.Review;
import com.example.frn.entity.User;
import io.swagger.v3.oas.models.security.SecurityScheme;

import org.apache.ibatis.annotations.*;

import java.util.List;
public interface ReviewMapper {
    @Insert("insert into review(content, user_id, film_id, review_id, replied_id, status)" +
            "value (#{content},#{userId},#{filmId},#{reviewId},#{repliedId},1)")
    int insert(Review review);
    @Update("update review set status=#{status} where id =#{id}")
    int updateStatus(@Param("id") Integer id,@Param("status") Integer status);
    @Update("update review set like_num=like_num+#{num} where id =#{id}")
    int updateLikeNum(@Param("id") Integer id,@Param("num") Integer num);
    @Update("update review set is_delete=1 where id =#{id}")
    int deleteById(Integer id);
    @Select("select * from review where is_delete = 0 and id=#{id}")
  @ResultMap("ReviewRM")
   Review selectById(Integer id);
    @Select("select * from review where is_delete=0 and review_id=#{param} and status=1")
    @Results({
            @Result(
                    property = "user",column= "use_id",javaType = User.class,
                    one = @One(select = "com.example.frn.dao.UserMapper.selectById")
            )
    })
    List<Review> selectListByReviewId(Integer reviewId);
    List<Review> selectList(@Param("filmId") Integer filmId,@Param("userId") Integer userId ,@Param("status")Integer status);


}
